<?php
/**
 * @package		Joomla.Site
 * @subpackage	mod_search
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;
$id = 1;
// FETCH COUNTRIES LIST
$db = JFactory::getDbo();
$q = "SELECT * FROM ".$db->quoteName('#__country_list')." WHERE id <> ''";
$db->setQuery($q);
$country_list = $db->loadObjectList();
	/*$db = JFactory::getDbo();
	$i =1;
	foreach($country_list as $country){
		$q = "INSERT INTO ".$db->quoteName('#__country_list')." VALUES(".$i.",".$db->quote($country).")";
		$db->setQuery($q);
		$result = $db->query();
		$i++;
	}*/
?>
	<form id="member-registration" action="<?php echo JRoute::_('index.php?option=com_users&task=registration.register'); ?>" method="post">
                <div class="input-block ip-col-2">
                    <input name="firstname" id="firstname" type="text" class="f-input i-toggle" value="<?php echo JText::_('MOD_SCAN_FNAME'); ?>">
                </div>
                <div class="input-block ip-col-2 col-last">
                    <input name="lastname" id="lastname"type="text" class="f-input i-toggle" value="<?php echo JText::_('MOD_SCAN_LNAME'); ?>">
                </div>
                <div class="input-block ip-col-2">
                    <input name="title" id="title" type="text" class="f-input i-toggle" value="<?php echo JText::_('MOD_SCAN_TITLE'); ?>">
                </div>
                <div class="input-block ip-col-2 col-last">
                    <input name="company" id="company" type="text" class="f-input i-toggle" value="<?php echo JText::_('MOD_SCAN_COMPANY'); ?>">
                </div>
                <div class="input-block ip-col-2">
                    <input name="email" id="email" type="text" class="f-input i-toggle" value="E-mail *">
                </div>
                <div class="input-block ip-col-2 col-last">
                    <input name="phone" id="phone" type="text" class="f-input i-toggle" value="<?php echo JText::_('MOD_SCAN_PHONE'); ?>">
                </div>
                <div class="input-block ip-col-2">
					
                    <select class="f-select" name="country" id="country">
						<option value="">--Select--</option>
						<?php foreach($country_list as $country):?>
                        <option value="<?php echo $country->id;?>" ><?php echo $country->name;?></option>
						<?php endforeach;?>
                    </select>
					
                </div>
                <div class="input-block ip-col-2 col-last">
                    <input name="state" id="state" type="text" class="f-input i-toggle" value="<?php echo JText::_('MOD_SCAN_STATE'); ?>">
                </div>
                <div class="input-block ip-col-2">
                    <input name="industry" id="industry" type="text" class="f-input i-toggle" value="<?php echo JText::_('MOD_SCAN_INDUSTRY'); ?>">
                </div>
				 <div class="input-block ip-col-2 col-last">
                    <input name="nodes" id="nodes" type="text" class="f-input i-toggle" value="<?php echo JText::_('MOD_SCAN_NODES'); ?>">
                </div>
                <div class="clear"></div>
                <div class="input-block">
                    <textarea name="message" id="message" class="i-toggle"><?php echo JText::_('MOD_SCAN_MESSAGE'); ?></textarea>
                </div>
                <div class="clr"></div>
                <div class="form-submit clearfix">
                    <a href="javascript:void(0)" onclick="jQuery('#member-registration').submit();" class="btnSend fll">Send</a>
                    <p id="p-field2"><?php echo JText::_('COM_ACYMAILING_REQUIRED_FIELDS'); ?></p>
                </div>
				<input type="hidden" name="option" value="com_users" />
				<input type="hidden" name="task" value="registration.register" />
				<input type="hidden" name="groupid" value="11" />
				<?php echo JHtml::_('form.token');?>
            </form>
               
 <?php                        	       
$input_fname = JText::_( 'Please Enter Your First Name' );
$input_lname = JText::_( 'Please Enter Your Last Name' );
$input_title = JText::_( 'Please Enter Your Title' );
$input_company = JText::_( 'Please Enter Your Company' );
$input_phone = JText::_( 'Please Enter Your Phone' );
$input_email = JText::_( 'Please Enter Your Email' );
$input_country = JText::_( 'Please Enter Your Country' );
$input_industry = JText::_( 'Please Enter Your Industry' );
$input_nodes = JText::_( 'Please Enter Your Estimated # of IP nodes' );
$input_message = JText::_( 'Please Enter Your Message' );

	
?>                        
 <script type="text/javascript">                   
jQuery(document).ready(function(jQuery) {
	jQuery.validator.addMethod('postalcode', function (value) { 
		if(value=='') return true;	
		return /^\d{4}$/.test(value); 
	   }, '');
	jQuery.validator.addMethod("notEqual", function(value, element, param) {
			return this.optional(element) || value !== param;
	});
		//jQuery("#postcode").mask("9999",{placeholder:""});  
		jQuery('#member-registration').validate(
			{
				errorPlacement: function(error, element) {			
			},
			invalidHandler: function(form, validator) {
			  var errors = validator.numberOfInvalids();
			if (errors) {
                //$('#alert').html(validator['errorList'][0]['message']);
				jQuery('#alert').html(validator['errorList'][0]['message']);
    			jQuery('#backoverlay').show();
    			jQuery('#show_popup').show();
            	jQuery('#f_focus').html(validator['errorList'][0]['element'].name);
				validator['errorList'][0]['element'].focus();
				
			  } else {
			  }
			},
			rules: {
				firstname:{
					required: true,
					notEqual: "<?php echo JText::_('MOD_SCAN_FNAME'); ?>",
				},
				lastname:{
					required: true,
					notEqual: "<?php echo JText::_('MOD_SCAN_LNAME'); ?>",
				},
				title:{
					required: true,
					notEqual: "<?php echo JText::_('MOD_SCAN_TITLE'); ?>",
				},
				company:{
					required: true,
					notEqual: "<?php echo JText::_('MOD_SCAN_COMPANY'); ?>",
				},	
				email:{
					required: true,
					email: true,
				},	
				phone:{
					required: true,
					digits:true,
					minlength:6,
				},
				country:{
					required: true,
				},
				industry:{
					required: true,
					notEqual: "<?php echo JText::_('MOD_SCAN_INDUSTRY'); ?>",
				},
				nodes:{
					required: true,
					digits:true,
					notEqual: "<?php echo JText::_('MOD_SCAN_NODES'); ?>",
				},
			},
			messages: {
				firstname: "<?php echo $input_fname; ?>",
				lastname: "<?php echo $input_lname; ?>",
				title: "<?php echo $input_title; ?>",
				company: "<?php echo $input_company; ?>",
				email: "<?php echo $input_email; ?>",
				phone: "<?php echo $input_phone; ?>",
				country: "<?php echo $input_country; ?>",
				industry: "<?php echo $input_industry; ?>",
				nodes: "<?php echo $input_nodes; ?>",
				
			
			}
		});
        close_popup=function(){		
			var fel=jQuery('#f_focus').html();
            jQuery('#backoverlay').hide();
    		jQuery('#show_popup').hide();
    		jQuery('#' + fel ).focus();		
      };
      
      
	});
</script>


